package org.paul.gotobplan.rest;

import org.androidannotations.rest.spring.annotations.*;
import org.androidannotations.rest.spring.api.MediaType;
import org.paul.gotobplan.bean.SaveBean;
import org.paul.gotobplan.bean.TokenBean;
import org.paul.gotobplan.bean.UserBean;
import org.paul.gotobplan.rest.helper.MyResponseErrorHandler;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;

import java.util.Map;

import static org.paul.gotobplan.BuildConfig.API_HOST_ISOFT;

@Rest(rootUrl = API_HOST_ISOFT,
        converters =
                {StringHttpMessageConverter.class,
                        GsonHttpMessageConverter.class},
//        requestFactory = HttpsClientRequestFactory.class,
//        interceptors = {HttpBasicAuthenticatorInterceptor.class},
        responseErrorHandler = MyResponseErrorHandler.class
)
public interface ISoftRestClient {
    void setHeader(String name, String value);

    void setBearerAuth(String token);

    String getHeader(String name);

//    @Headers({
//            @Header(name = "Host", value = "api.isoftstone.com"),
//            @Header(name = "Pragma", value = "no-cache"),
//            @Header(name = "Cache-Control", value = "no-cache"),
//            @Header(name = "Access-Control-Request-Method", value = "POST"),
//            @Header(name = "Origin", value = "http://i.isoftstone.com"),
//            @Header(name = "User-Agent", value = "Mozilla/5.0 (Linux; Android 8.1.0; Redmi Note 5 Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36;iPSAClient"),
//            @Header(name = "Access-Control-Request-Headers", value = "content-type"),
//            @Header(name = "Accept", value = "*/*"),
//            @Header(name = "Accept-Encoding", value = "gzip, deflate"),
//            @Header(name = "Accept-Language", value = "zh-CN,en-US;q=0.9"),
//            @Header(name = "X-Requested-With", value = "com.isoftstone.client.ipsa"),
//            @Header(name = "Connection", value = "keep-alive")})
//    @Options("/token")
//    Set<HttpMethod> preToken();

    @Headers({
            @Header(name = "User-Agent", value = "Mozilla/5.0 (Linux; Android 8.1.0; Redmi Note 5 Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36;iPSAClient"),
            @Header(name = "Referer", value = "http://i.isoftstone.com/kaoqindakaweixinDTG/huawei.html?"),
            @Header(name = "Accept-Language", value = "zh-CN"),
            @Header(name = "Content-Type", value = "application/json"),
            @Header(name = "Origin", value = "http://i.isoftstone.com")
    })
    @Post("/token")
    @Accept(MediaType.ALL)
    TokenBean token();

    @Headers({
            @Header(name = "User-Agent", value = "Mozilla/5.0 (Linux; Android 8.1.0; Redmi Note 5 Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36;iPSAClient"),
            @Header(name = "Referer", value = "http://i.isoftstone.com/kaoqindakaweixinDTG/huawei.html?"),
            @Header(name = "Accept-Language", value = "zh-CN"),
            @Header(name = "Content-Type", value = "application/json"),
            @Header(name = "Origin", value = "http://i.isoftstone.com")
    })
    @Post("/user")
    @Accept(MediaType.ALL)
    @RequiresAuthentication
    UserBean user(@Body Map<String, Object> userInfo);

    @Headers({
            @Header(name = "User-Agent", value = "Mozilla/5.0 (Linux; Android 8.1.0; Redmi Note 5 Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36;iPSAClient"),
            @Header(name = "Referer", value = "http://i.isoftstone.com/kaoqindakaweixinDTG/huawei.html?"),
            @Header(name = "Accept-Language", value = "zh-CN"),
            @Header(name = "Content-Type", value = "application/json"),
            @Header(name = "Origin", value = "http://i.isoftstone.com")
    })
    @Post("/save")
    @Accept(MediaType.ALL)
    @RequiresAuthentication
    SaveBean am(@Body Map<String, Object> userInfo);

    @Headers({
            @Header(name = "User-Agent", value = "Mozilla/5.0 (Linux; Android 8.1.0; Redmi Note 5 Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36;iPSAClient"),
            @Header(name = "Referer", value = "http://i.isoftstone.com/kaoqindakaweixinDTG/huawei.html?"),
            @Header(name = "Accept-Language", value = "zh-CN"),
            @Header(name = "Content-Type", value = "application/json"),
            @Header(name = "Origin", value = "http://i.isoftstone.com")
    })
    @Post("/save")
    @Accept(MediaType.ALL)
    @RequiresAuthentication
    SaveBean pm(@Body Map<String, Object> userInfo);
}
